<template>
	<view class="container">
		<view class="header">
		<uni-datetime-picker v-model="range" type="daterange" @change="change" />
		</view>
		<view style="height:70rpx"></view>
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index">
				<view class="item-content item-order">单号：{{ item.code }}</view>
				<view class="item-content">创建时间：{{ item.created_at }}</view>
				<view class="bottom gui-border-t">
					<view>共{{ item.goods_class_num }}种，{{ item.goods_num }}件</view>
					<view class="gui-color-blue" @click="toDetail(item)">详情</view>
				</view>
			</view>
		</view>
		<view class="footer">
			<view class="gui-text-center gui-bg-light footer-button" hover-class="gui-tap" @click="toAdd">
				<text
					class="gui-text gui-color-white gui-footer-large-button-text gui-block-text gui-text-center">新建盘点单</text>
			</view>
		</view>
		<view style="height:100rpx"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				range:[]
			}
		},
		onShow(){
			
		},
		onLoad() {
			//this.date = this.$dayjs().format('YYYY-MM-DD');
		},
		mounted(){
			this.getList()
		},
		onShareAppMessage(res) {
			
		},
		onPullDownRefresh(){
			this.getList()
		},
		methods: {
			async getList(){
				let res = await this.$http.post(`/admin/shop?route=plugin.store-cashier.store.admin.goodsStock.getStockBatchList`,{
					batch_type:'4',
					category:"",
					code:"",
					option_type:"",
					page:1,
					times:this.times
				})
				this.list = res.data.list.data;
				uni.stopPullDownRefresh()
			},
			toAdd() {
				uni.navigateTo({
					url: `/pages/inventory/add`
				})
			},
			toDetail(item){
				uni.navigateTo({
					url: `/pages/inventory/detail?id=${item.id}&code=${item.code}&remark=${item.note || ''}`
				})
			},
			change(e){
				if(e.length === 0){
					this.times = ''
					this.getList()
					return false;
				}
				this.times = [this.$dayjs(e[0]).valueOf(),this.$dayjs(e[1]).valueOf()]
				this.getList()
			}
		}
		
	}
</script>
<style scoped lang="scss">
	.list {
		margin:20rpx;
		.item{
			background-color: #fff;
			border-radius:20rpx;
			padding:30rpx;
			margin-bottom: 30rpx;
			color:#666;
			.bottom{
				display: flex;
				justify-content: space-between;
				margin-top:20rpx;
				line-height: 1;
				padding-top: 20rpx;
				font-weight: bold;
			}
			.item-content{
				line-height: 2;
			}
			.item-order{
				font-weight: bold;
				font-size:36rpx;
			}
		}
	}
	.gui-bg-light{
		background-color: #9e7e35;
	}
	.header{
		background-color: #fff;
		position: fixed;
		top:40px;
		left:0;
		width: 100%;
		z-index: 20;
		
	}
	.footer{
		width: 100%;
		background-color: #fff;
	}
</style>